package com.raylu.realtime.app.func;

import com.raylu.realtime.utils.KeywordUtil;
import org.apache.flink.table.annotation.DataTypeHint;
import org.apache.flink.table.annotation.FunctionHint;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;

import java.io.IOException;
import java.util.List;

/**
 * Description:
 * <p>
 * Create by lucienoz on 2022/1/13.
 * Copyright © 2022 lucienoz. All rights reserved.
 */
@FunctionHint(output = @DataTypeHint("ROW<keyword STRING>"))
public class KeywordTableFunctionByIk extends TableFunction<Row> {


    public void eval(String line) throws IOException {

        List<String> keyword = KeywordUtil.getKeyword(line);
        for (String s : keyword) {
            collect(Row.of(s));
        }

    }
}
